<template>
<div>
    <h1>房号信息录入</h1>
    <table class="table">
        <tr>
            <td>房号名称</td>
            <td><input type="text" v-model="data.fangName"></td>
        </tr>

        <tr>
            <td>房号</td>
            <td><input type="text" v-model="data.fHao"></td>
        </tr>

        <tr>
            <td>状态</td>
            <td>
                <input type="radio" name="zt" value="1" checked v-model="data.zt">上架
                <input type="radio" name="zt" value="2" v-model="data.zt">下架
            </td>
        </tr>

        <tr>
            <td></td>
            <td><input type="button" value="添加" @click="FAdd()"></td>
        </tr>

    </table>
</div>

</template>

<script setup lang="ts">
import {ref,onMounted} from 'vue';
import axios from 'axios';
import { useRouter } from 'vue-router';
const router=useRouter()

const data=ref({
  "fid": 0,
  "fangName": "",
  "fHao": "",
  "fangTime": "2025-06-16T10:24:40.021Z",
  "zt": 0
})


const FAdd=()=>{
    axios.post("/api/Fang/Add",data.value).then(res=>{
        if(res.data>0){
            alert("添加成功");
            router.push("/FShow")
        }else{
            alert("添加失败");
        }
    })
}    
</script>

<style lang="scss" scoped>

</style>